Fix for #119722, reported by Olexiy Avramchenko, patch by Owen Taylor.
authorSoeren Sandmann <sandmann@daimi.au.dk>
Tue, 17 Feb 2004 22:05:47 +0000 (22:05 +0000)
committerSøren Sandmann Pedersen <ssp@src.gnome.org>
Tue, 17 Feb 2004 22:05:47 +0000 (22:05 +0000)
Tue Feb 17 23:02:58 2004  Soeren Sandmann  <sandmann@daimi.au.dk>

Fix for #119722, reported by Olexiy Avramchenko, patch by Owen
Taylor.

* gdk/x11/gdkprivate-x11.h (struct _GdkGCX11): Add a depth field

* gdk/x11/gdkgc-x11.c (_gdk_x11_gc_new): Keep track of the GC's
depth.

* gdk/x11/gdkgc-x11.c (_gdk_gc_x11_get_fg_xft_color): First query
the colormap, if no colormap, special case depth 1,

* gdk/x11/gdkgc-x11.c (_gdk_x11_gc_get_fg_picture): Use
_gdk_gc_x11_get_fg_xft_color() to get the foreground color.

* gdk/x11/gdkdrawable-x11.c (gdk_x11_drawable_get_xft_draw):
Special-case bitmaps without a colormap.

* gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_pixbuf): Use inherited
draw_pixbuf() implementation in the bitmap case.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/x11/gdkdrawable-x11.c
gdk/x11/gdkgc-x11.c
gdk/x11/gdkprivate-x11.h

index bb696fc561b9e5cb1110267bd153adebe4001505..19f9521b7502292189dce6dfb8c236b0a3dd294d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+Tue Feb 17 23:02:58 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       Fix for #119722, reported by Olexiy Avramchenko, patch by Owen
+       Taylor.
+
+       * gdk/x11/gdkprivate-x11.h (struct _GdkGCX11): Add a depth field
+
+       * gdk/x11/gdkgc-x11.c (_gdk_x11_gc_new): Keep track of the GC's
+       depth.
+
+       * gdk/x11/gdkgc-x11.c (_gdk_gc_x11_get_fg_xft_color): First query
+       the colormap, if no colormap, special case depth 1, 
+
+       * gdk/x11/gdkgc-x11.c (_gdk_x11_gc_get_fg_picture): Use
+       _gdk_gc_x11_get_fg_xft_color() to get the foreground color.
+
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_drawable_get_xft_draw):
+       Special-case bitmaps without a colormap.
+
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_pixbuf): Use inherited
+       draw_pixbuf() implementation in the bitmap case.
+
 2004-02-17  Mark McLoughlin  <mark@skynet.ie>
 
        * modules/input/Makefile.am: only reference input method
index bb696fc561b9e5cb1110267bd153adebe4001505..19f9521b7502292189dce6dfb8c236b0a3dd294d 100644 (file)
@@ -1,3 +1,25 @@
+Tue Feb 17 23:02:58 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       Fix for #119722, reported by Olexiy Avramchenko, patch by Owen
+       Taylor.
+
+       * gdk/x11/gdkprivate-x11.h (struct _GdkGCX11): Add a depth field
+
+       * gdk/x11/gdkgc-x11.c (_gdk_x11_gc_new): Keep track of the GC's
+       depth.
+
+       * gdk/x11/gdkgc-x11.c (_gdk_gc_x11_get_fg_xft_color): First query
+       the colormap, if no colormap, special case depth 1, 
+
+       * gdk/x11/gdkgc-x11.c (_gdk_x11_gc_get_fg_picture): Use
+       _gdk_gc_x11_get_fg_xft_color() to get the foreground color.
+
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_drawable_get_xft_draw):
+       Special-case bitmaps without a colormap.
+
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_pixbuf): Use inherited
+       draw_pixbuf() implementation in the bitmap case.
+
 2004-02-17  Mark McLoughlin  <mark@skynet.ie>
 
        * modules/input/Makefile.am: only reference input method
index bb696fc561b9e5cb1110267bd153adebe4001505..19f9521b7502292189dce6dfb8c236b0a3dd294d 100644 (file)
@@ -1,3 +1,25 @@
+Tue Feb 17 23:02:58 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       Fix for #119722, reported by Olexiy Avramchenko, patch by Owen
+       Taylor.
+
+       * gdk/x11/gdkprivate-x11.h (struct _GdkGCX11): Add a depth field
+
+       * gdk/x11/gdkgc-x11.c (_gdk_x11_gc_new): Keep track of the GC's
+       depth.
+
+       * gdk/x11/gdkgc-x11.c (_gdk_gc_x11_get_fg_xft_color): First query
+       the colormap, if no colormap, special case depth 1, 
+
+       * gdk/x11/gdkgc-x11.c (_gdk_x11_gc_get_fg_picture): Use
+       _gdk_gc_x11_get_fg_xft_color() to get the foreground color.
+
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_drawable_get_xft_draw):
+       Special-case bitmaps without a colormap.
+
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_pixbuf): Use inherited
+       draw_pixbuf() implementation in the bitmap case.
+
 2004-02-17  Mark McLoughlin  <mark@skynet.ie>
 
        * modules/input/Makefile.am: only reference input method
index bb696fc561b9e5cb1110267bd153adebe4001505..19f9521b7502292189dce6dfb8c236b0a3dd294d 100644 (file)
@@ -1,3 +1,25 @@
+Tue Feb 17 23:02:58 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       Fix for #119722, reported by Olexiy Avramchenko, patch by Owen
+       Taylor.
+
+       * gdk/x11/gdkprivate-x11.h (struct _GdkGCX11): Add a depth field
+
+       * gdk/x11/gdkgc-x11.c (_gdk_x11_gc_new): Keep track of the GC's
+       depth.
+
+       * gdk/x11/gdkgc-x11.c (_gdk_gc_x11_get_fg_xft_color): First query
+       the colormap, if no colormap, special case depth 1, 
+
+       * gdk/x11/gdkgc-x11.c (_gdk_x11_gc_get_fg_picture): Use
+       _gdk_gc_x11_get_fg_xft_color() to get the foreground color.
+
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_drawable_get_xft_draw):
+       Special-case bitmaps without a colormap.
+
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_pixbuf): Use inherited
+       draw_pixbuf() implementation in the bitmap case.
+
 2004-02-17  Mark McLoughlin  <mark@skynet.ie>
 
        * modules/input/Makefile.am: only reference input method
index bb696fc561b9e5cb1110267bd153adebe4001505..19f9521b7502292189dce6dfb8c236b0a3dd294d 100644 (file)
@@ -1,3 +1,25 @@
+Tue Feb 17 23:02:58 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       Fix for #119722, reported by Olexiy Avramchenko, patch by Owen
+       Taylor.
+
+       * gdk/x11/gdkprivate-x11.h (struct _GdkGCX11): Add a depth field
+
+       * gdk/x11/gdkgc-x11.c (_gdk_x11_gc_new): Keep track of the GC's
+       depth.
+
+       * gdk/x11/gdkgc-x11.c (_gdk_gc_x11_get_fg_xft_color): First query
+       the colormap, if no colormap, special case depth 1, 
+
+       * gdk/x11/gdkgc-x11.c (_gdk_x11_gc_get_fg_picture): Use
+       _gdk_gc_x11_get_fg_xft_color() to get the foreground color.
+
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_drawable_get_xft_draw):
+       Special-case bitmaps without a colormap.
+
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_pixbuf): Use inherited
+       draw_pixbuf() implementation in the bitmap case.
+
 2004-02-17  Mark McLoughlin  <mark@skynet.ie>
 
        * modules/input/Makefile.am: only reference input method
index 3dbd8c1fa25882ec66fe9c699bca5e0930d6ea16..e5d4b30e0d227f6da1a8b2aa7f80417d9164ef9c 100644 (file)
@@ -312,22 +312,29 @@ gdk_x11_drawable_get_xft_draw (GdkDrawable *drawable)
    if (impl->xft_draw == NULL)
     {
       GdkColormap *colormap = gdk_drawable_get_colormap (drawable);
-      GdkVisual *visual;
+      
+      if (colormap)
+       {
+          GdkVisual *visual;
 
-      if (!colormap)
+          visual = gdk_colormap_get_visual (colormap);
+      
+          impl->xft_draw = XftDrawCreate (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,
+                                         GDK_VISUAL_XVISUAL (visual), GDK_COLORMAP_XCOLORMAP (colormap));
+       }
+      else if (gdk_drawable_get_depth (drawable) == 1)
        {
+         impl->xft_draw = XftDrawCreateBitmap (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid);
+       }
+      else
+        {
          g_warning ("Using Xft rendering requires the drawable argument to\n"
                     "have a specified colormap. All windows have a colormap,\n"
                     "however, pixmaps only have colormap by default if they\n"
                     "were created with a non-NULL window argument. Otherwise\n"
                     "a colormap must be set on them with gdk_drawable_set_colormap");
-         return NULL;
-       }
-
-      visual = gdk_colormap_get_visual (colormap);
-      
-      impl->xft_draw = XftDrawCreate (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,
-                                     GDK_VISUAL_XVISUAL (visual), GDK_COLORMAP_XCOLORMAP (colormap));
+         return NULL;
+        }
     }
 
    return impl->xft_draw;
@@ -1421,6 +1428,7 @@ gdk_x11_draw_pixbuf (GdkDrawable     *drawable,
 
   if (format_type == FORMAT_NONE ||
       !gdk_pixbuf_get_has_alpha (pixbuf) ||
+      gdk_drawable_get_depth (drawable) == 1 ||
       (dither == GDK_RGB_DITHER_MAX && gdk_drawable_get_depth (drawable) != 24) ||
       gdk_x11_drawable_get_picture (drawable) == None)
     {
index 52d460b5c3d804177a01a1a3ebce40ede6d968f4..f5cbae9df5f185599e5744e7cd9e0c1fa4cb21c6 100644 (file)
@@ -143,6 +143,8 @@ _gdk_x11_gc_new (GdkDrawable      *drawable,
     
   private->screen = GDK_DRAWABLE_IMPL_X11 (drawable)->screen;
 
+  private->depth = gdk_drawable_get_depth (drawable);
+
   if (values_mask & (GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN))
     {
       values_mask &= ~(GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN);
@@ -857,9 +859,8 @@ Picture
 _gdk_x11_gc_get_fg_picture (GdkGC *gc)
 {
   GdkGCX11 *x11_gc;
-  GdkColormap *cmap;
   gboolean new = FALSE;
-  GdkColor color;
+  XftColor xftcolor;
   
   g_return_val_if_fail (GDK_IS_GC_X11 (gc), None);
 
@@ -867,7 +868,6 @@ _gdk_x11_gc_get_fg_picture (GdkGC *gc)
     return None;
 
   x11_gc = GDK_GC_X11 (gc);
-  cmap = gdk_gc_get_colormap (gc);
 
   if (x11_gc->fg_picture == None)
     {
@@ -891,17 +891,16 @@ _gdk_x11_gc_get_fg_picture (GdkGC *gc)
       new = TRUE;
     }
 
-  gdk_colormap_query_color (cmap, x11_gc->fg_pixel, &color);
-
+  _gdk_gc_x11_get_fg_xft_color (gc, &xftcolor);
+  
   if (new ||
-      x11_gc->fg_picture_color.red != color.red ||
-      x11_gc->fg_picture_color.green != color.green ||
-      x11_gc->fg_picture_color.blue != color.blue)
+      x11_gc->fg_picture_color.red != xftcolor.color.red ||
+      x11_gc->fg_picture_color.green != xftcolor.color.green ||
+      x11_gc->fg_picture_color.blue != xftcolor.color.blue)
     {
-      x11_gc->fg_picture_color.red = color.red;
-      x11_gc->fg_picture_color.green = color.green;
-      x11_gc->fg_picture_color.blue = color.blue;
-      x11_gc->fg_picture_color.alpha = 0xffff;
+      x11_gc->fg_picture_color.red = xftcolor.color.red;
+      x11_gc->fg_picture_color.green = xftcolor.color.green;
+      x11_gc->fg_picture_color.blue = xftcolor.color.blue;
 
       XRenderFillRectangle (GDK_GC_XDISPLAY (gc), PictOpSrc, 
                            x11_gc->fg_picture, &x11_gc->fg_picture_color,
@@ -929,13 +928,46 @@ _gdk_gc_x11_get_fg_xft_color (GdkGC    *gc,
   g_return_if_fail (GDK_IS_GC_X11 (gc));
 
   x11_gc = GDK_GC_X11 (gc);
+
   cmap = gdk_gc_get_colormap (gc);
 
   xftcolor->pixel = x11_gc->fg_pixel;
 
-  gdk_colormap_query_color (cmap, xftcolor->pixel, &color);
-  xftcolor->color.red = color.red;
-  xftcolor->color.green = color.green;
-  xftcolor->color.blue = color.blue;
-  xftcolor->color.alpha = 0xffff;
+  if (cmap)
+    {
+      gdk_colormap_query_color (cmap, xftcolor->pixel, &color);
+      xftcolor->color.alpha = 0xffff;
+      xftcolor->color.red = color.red;
+      xftcolor->color.green = color.green;
+      xftcolor->color.blue = color.blue;
+    }
+  else if (x11_gc->depth == 1)
+    {
+      /* Drawing with Xft on a bitmap is a bit bizzare; it
+       * takes alpha >= 0x8000 to mean 'set to 1' and
+       * alpha < 0x8000 to mean 'set to 0'.
+       */
+      if (xftcolor->pixel)
+        {
+         xftcolor->color.red = 0xffff;
+         xftcolor->color.green = 0xffff;
+         xftcolor->color.blue = 0xffff;
+         xftcolor->color.alpha = 0xffff;
+       }
+      else
+        {
+         xftcolor->color.red = 0;
+         xftcolor->color.green = 0;
+         xftcolor->color.blue = 0;
+         xftcolor->color.alpha = 0;
+       }
+    }
+  else
+    {
+      g_warning ("Using Xft rendering requires the GC argument to have a\n"
+                "specified colormap. If the GC was created for a drawable\n"
+                "with a colormap, the colormap will be set on the GC\n"
+                "automatically. Otherwise, a colormap must be set on it with"
+                "gdk_gc_set_colormap");
+    }
 }
index 98efc532109b38a926f76e5ac9c0137b748855a2..5ded4338aac902f965a3824617f24dc513d831fb 100644 (file)
@@ -64,6 +64,7 @@ struct _GdkGCX11
   GdkRegion *clip_region;
   guint16 dirty_mask;
   guint have_clip_mask : 1;
+  guint depth : 8;
 
   Picture fg_picture;
   XRenderColor fg_picture_color;